package com.mzj.saas.mservice.records.repository;

import com.mzj.saas.mservice.records.entity.HousePutLiability;
import org.springframework.data.jpa.repository.JpaSpecificationExecutor;
import org.springframework.data.jpa.repository.Modifying;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.PagingAndSortingRepository;

import java.util.List;

public interface HousePutLiabilityRepository extends PagingAndSortingRepository<HousePutLiability, String>, JpaSpecificationExecutor<HousePutLiability> {
    HousePutLiability findByCommunityIdAndEnableStatusAndStatus(Long communityId, Integer enableStatus, Integer status);

    HousePutLiability findByLiabilityNumber(String liabilityNumber);

    @Modifying
    @Query(value = "UPDATE `saas_house_put_liability` l SET l.status=?2 WHERE l.`liability_number` = ?1", nativeQuery = true)
    int updateEnableStatus(String liabilityNumber, Integer status);

    List<HousePutLiability> findByCommunityIdAndStatus(Long communityId, Integer status);
}
